package com.zz.inventory.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.zz.inventory.domain.ExamClients;
import com.zz.inventory.service.IExamClientsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 考试客户端关联Controller
 * 
 * @author ruoyi
 * @date 2025-07-04
 */
@RestController
@RequestMapping("/clients")
public class ExamClientsController extends BaseController
{
    @Autowired
    private IExamClientsService examClientsService;

    /**
     * 查询考试客户端关联列表
     */
    @RequiresPermissions("Teacher:clients:list")
    @GetMapping("/list")
    public TableDataInfo list(ExamClients examClients)
    {
        startPage();
        List<ExamClients> list = examClientsService.selectExamClientsList(examClients);
        return getDataTable(list);
    }

    /**
     * 导出考试客户端关联列表
     */
    @RequiresPermissions("Teacher:clients:export")
    @Log(title = "考试客户端关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamClients examClients)
    {
        List<ExamClients> list = examClientsService.selectExamClientsList(examClients);
        ExcelUtil<ExamClients> util = new ExcelUtil<ExamClients>(ExamClients.class);
        util.exportExcel(response, list, "考试客户端关联数据");
    }

    /**
     * 获取考试客户端关联详细信息
     */
    @RequiresPermissions("Teacher:clients:query")
    @GetMapping(value = "/{examClientId}")
    public AjaxResult getInfo(@PathVariable("examClientId") Long examClientId)
    {
        return success(examClientsService.selectExamClientsByExamClientId(examClientId));
    }

    /**
     * 新增考试客户端关联
     */
    @RequiresPermissions("Teacher:clients:add")
    @Log(title = "考试客户端关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamClients examClients)
    {
        return toAjax(examClientsService.insertExamClients(examClients));
    }

    /**
     * 修改考试客户端关联
     */
    @RequiresPermissions("Teacher:clients:edit")
    @Log(title = "考试客户端关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamClients examClients)
    {
        return toAjax(examClientsService.updateExamClients(examClients));
    }

    /**
     * 删除考试客户端关联
     */
    @RequiresPermissions("Teacher:clients:remove")
    @Log(title = "考试客户端关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examClientIds}")
    public AjaxResult remove(@PathVariable Long[] examClientIds)
    {
        return toAjax(examClientsService.deleteExamClientsByExamClientIds(examClientIds));
    }



}
